import java.util.Scanner;

public class Main1659 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = a / 10000;//1
        int c = (a % 10000) / 1000;//2
        int d = ((a % 10000) % 1000) / 100;//3
        int e = (a / 10) % 10;//4
        int f = a % 10;//5
        if (b == 5 || c == 5 || d == 5 || e == 5 || f == 5 && a >= 10000 && a <= 99999) {
            System.out.println(b + c + d + e + f);

        } else {
            System.out.println(a);
        }
    }
}